package com.guigu.ssyx.common.exception;

import com.guigu.ssyx.common.result.ResultCodeEnum;
import lombok.Data;

@Data
public class SsyxException extends RuntimeException {
    private Integer code;

    /**
     * 通过状态吗和错误消息状态异常对象
     * @param code 状态码
     * @param message 错误消息
     * */
    public SsyxException(Integer code, String message){
        super(message);
        this.code = code;
    }

    /**
     * 通过状态枚举状态异常对象
     * @param resultCodeEnum 状态枚举
     * */
    public SsyxException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "SsyxException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}
